Ext.define('appmod.view.user.UserForm', {
    extend: 'Ext.form.Panel',
    alias: 'widget.userform',
    bodyPadding: 10,
	
    initComponent: function() {
      var me = this;
	  
	  var required = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';

    Ext.apply(Ext.form.field.VTypes, {
        password: function(val, field) {
            if (field.initialPassField) {
				var pwd = field.up('form').down('#' + field.initialPassField);
				
                return (val == pwd.getValue());
            }
            return true;
        },

        passwordText: '密码不匹配'
    }); 

      Ext.applyIf(me, {
	  	    fieldDefaults: {
            	labelWidth: 80
        	},
            items: [
                {
                    xtype: 'textfield',
                    name: 'name',
                    fieldLabel: '帐号名称',
					anchor: '95%',
					allowBlank:false
                },
                {
                    xtype: 'textfield',
                    name: 'code',
                    anchor: '95%',
					fieldLabel: '帐号编码'
                },
                {
                    xtype: 'hiddenfield',
                    name: 'id',
                    fieldLabel: 'id'
                },
                {
                    xtype: 'radiogroup',
                    fieldLabel: '禁止使用',
					columns: 2,
            		vertical: true,
                    items: [
                        {
                            xtype: 'radiofield',
							name:'disabled',
                            boxLabel: '否',
							checked:true,
                            inputValue: 0
                        },
                        {
                            xtype: 'radiofield',
                            name:'disabled',
							boxLabel: '是',
                            inputValue: 1
                        }
                    ]
                },
				{
					xtype: 'container',
            		anchor: '95%',
            		layout: 'hbox',
			  	    fieldDefaults: {
		            	labelWidth: 65
		        	},					
					items:[{
		                xtype: 'container',
        	        	flex: 1,
            	    	layout: 'anchor',
               		 	items: [
						{
                    		xtype:'textfield',
                    		fieldLabel: '手机',
                    		name: 'mobilephone',
                    		anchor:'95%'
                		}, {
                    		xtype:'textfield',
                    		fieldLabel: '电子邮箱',
                    		name: 'email',
							vtype:'email',
                    		anchor:'95%'
                		}]
            		},{
		                xtype: 'container',
		                flex: 1,
		                layout: 'anchor',
		                items: [{
		                    xtype:'textfield',
		                    fieldLabel: '办公电话',
		                    name: 'officephone',
		                    anchor:'100%'
		                },{
		                    xtype:'textfield',
		                    fieldLabel: 'QQ',
		                    name: 'qq',
		                    anchor:'100%'
		                }]
            		}
					]
				},
                {
                    xtype: 'fieldset',
                    title: '初始密码设定',
			        anchor: '95%',
					defaults: {
			            inputType: 'password'
			        },					
                    items: [
                        {
                            xtype: 'textfield',
                            fieldLabel: '初始输入密码',
							name:'password',
							itemId: 'pwd'
                        },
                        {
                            xtype: 'textfield',
							vtype:'password',
							initialPassField: 'pwd',
                            fieldLabel: '再次确认'
                        }
                    ]
                },
                {
                    xtype: 'textareafield',
					name:'remark',
                    fieldLabel: '备 注',
                    anchor: '95%'
                },
				
				{
					xtype: 'container',
            		anchor: '100%',
            		layout: 'hbox',
			  	    fieldDefaults: {
		            	labelWidth: 65
		        	},					
					items:[{
		                xtype: 'container',
        	        	flex: 1,
            	    	layout: 'anchor',
               		 	items: [
						{
                    		xtype:'displayfield',
                    		fieldLabel: '创建日期',
                    		name: 'createdDate',
                    		anchor:'95%'
                		}, {
                    		xtype:'displayfield',
                    		fieldLabel: '创建人',
                    		name: 'createdUser',
                    		anchor:'95%'
                		}]
            		},{
		                xtype: 'container',
		                flex: 1,
		                layout: 'anchor',
		                items: [
						{
                    		xtype:'displayfield',
                    		fieldLabel: '更新日期',
                    		name: 'updatedDate',
                    		anchor:'95%'
                		}, {
                    		xtype:'displayfield',
                    		fieldLabel: '更新人',
                    		name: 'updatedUser',
                    		anchor:'95%'
                		}]
            		}
					]
				}								
            ]			
        });

        me.callParent(arguments);
    }

});